package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.example.demo.db.pojo.TestPo;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: wuhong-016
 * @time: 2021/3/23 13:00
 * @version: v1.0.0
 * @description:TODO
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestService testService;

    @GetMapping("/select")
    public String select() {
        String id = "1";
        TestPo po1 = testService.select1(id);
        print("ds1", po1);
        TestPo po2 = testService.select2(id);
        print("ds2", po2);
        TestPo po3 = testService.select3(id);
        print("ds3", po3);
        TestPo po4 = testService.select4(id);
        print("default", po4);
        return "ok";
    }

    private void print(String key, Object obj) {
        if (null == obj) {
            System.out.println(key + " print >>> " + "null");
        } else {
            System.out.println(key + " print >>> " + JSON.toJSONString(obj));
        }
    }

}
